package com.yzf.demo.demo.ReflectionMechanism;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;

/**
 * Created by 于占峰 on 2020/3/25/025.
 */
public class GetConstructorAndGetDeclaredConstructor {
    public static void main(String[] args) throws NoSuchMethodException {
        Class clazz = DemoBean.class;
        Constructor declaredConstructor = clazz.getDeclaredConstructor();
        Constructor declaredConstructor2 = clazz.getDeclaredConstructor(String.class, Integer.class);
        Constructor declaredConstructor3 = clazz.getDeclaredConstructor(String.class);
        Constructor constructor = clazz.getConstructor();
        Constructor constructor2 = clazz.getConstructor(String.class, Integer.class);
        //Constructor constructor3 = clazz.getConstructor(Integer.class); //私有的构造函数 会报错
        System.out.println(declaredConstructor);
        System.out.println(declaredConstructor2);
        System.out.println(declaredConstructor3);
        System.out.println(constructor);
        System.out.println(constructor2);
    }
}
